<!DOCTYPE html>
<html lang="en" xmlns:th="www.thymeleaf.org" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/png" href="assets/img/favicon.ico">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title></title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    <meta name="viewport" content="width=device-width" />


    <!-- Bootstrap core CSS     -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />

    <!-- Animation library for notifications   -->
    <link href="assets/css/animate.min.css" rel="stylesheet"/>

    <!--  Light Bootstrap Table core CSS    -->
    <link href="assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>


    <!--  CSS for Demo Purpose, don't include it in your project     -->
    <link href="assets/css/demo.css" rel="stylesheet" />


    <!--     Fonts and icons     -->
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
    <link href="assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入VUE库 -->
    <script src="http://lib.baomitu.com/vue/2.6.12/vue.min.js"></script>
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="assets/js/axios.min.js"></script>
</head>
<body>
<el-dialog class="col-md-8" :visible.sync="dia" th:fragment="dial">
    <div class="card">
        <div class="header">
            <h4 class="title">修改信息</h4>
        </div>
        <div class="content">
<!--            <form>-->
                <div class="row">
                    <div class="col-md-5">
                        <div class="form-group">
                            <label>账号</label>
                            <input name="id"  type="hidden" v-model="user.id">
                            <span style="width: auto;height: auto">{{user.account}}</span>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="form-group">
                            <label>姓名</label>
                            <input type="text" name="name" maxlength="20" class="form-control" placeholder="Username"  v-model="user.name">
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label for="exampleInputEmail1">邮箱地址</label>
                            <input type="email" name="email" maxlength="20" class="form-control" placeholder="Email" v-model="user.email">
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>密码</label>
                            <input type="password" name="password" maxlength="50" class="form-control" placeholder="password" v-model="user.password">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label>联系方式</label>
                            <input type="text" name="phone" maxlength="20" class="form-control" placeholder="phone" v-model="user.phone">
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-12">
                        <div class="form-group">
                            <label>地址</label>
                            <input type="text" name="address" maxlength="50" class="form-control" placeholder="Home Address" v-model="user.address">
                        </div>
                    </div>
                </div>

                <button type="submit" class="btn btn-info btn-fill pull-right" v-on:click="updateUser()">修改</button>
                <div class="clearfix"></div>
<!--            </form>-->
        </div>
    </div>
</el-dialog>
<style>
    .col-md-8 {
        width: 60%; margin: 100px auto 50px 300px;
    }
</style>
</body>
<!--   Core JS Files   -->
<script src="assets/js/jquery-1.10.2.js" type="text/javascript"></script>
<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>

<!--  Checkbox, Radio & Switch Plugins -->
<script src="assets/js/bootstrap-checkbox-radio-switch.js"></script>

<!--  Charts Plugin -->
<script src="assets/js/chartist.min.js"></script>

<!--  Notifications Plugin    -->
<script src="assets/js/bootstrap-notify.js"></script>

<!--  Google Maps Plugin    -->
<!---<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>--->

<!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
<script src="assets/js/light-bootstrap-dashboard.js"></script>

<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
<script src="assets/js/demo.js"></script>
<script>
    var v = new Vue({
        el:".card",
        data:{
            user:{}
        },
        mounted:function () {
             axios.get("personinit").then(res=>{
                 if(res.data.data==null){
                     window.location.href="login";
                 }else{
                     this.user=res.data.data;
                 }
             })
        },
        methods:{
            updateUser:function () {
                let url = "adminUser/updateUser";
                let params = new URLSearchParams();
                params.append("id",this.user.id);
                params.append("name",this.user.name);
                params.append("account",this.user.account);
                params.append("email",this.user.email);
                params.append("password",this.user.password);
                params.append("phone",this.user.phone);
                params.append("address",this.user.address);
                axios.post(url,params).then(res=>{
                    if(res.data.code==1){
                        this.user=res.data.data;
                        window.location.href="logout";
                    }else{
                        alert(res.data.msg);
                        window.location.href="edituser";
                    }
                })
            }
        }

    })
</script>
</html>